Skip to content

feat(agents): add planner support to LlmAgent - #948

Merged
ScottMansfield merged 1 commit into
mainfrom
foundry/beb524be-3436-4f49-ae3d-7075df43c20c
Sep 25, 2026
Merged

ScottMansfield merged 1 commit into
mainfrom
foundry/beb524be-3436-4f49-ae3d-7075df43c20c

Conversation

@ScottMansfield

@ScottMansfield ScottMansfield commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

2. Or, if no issue exists, describe the change:

Problem:
BasePlanner, BuiltInPlanner and PlanReActPlanner are exported, but nothing uses them: LlmAgent has no planner field and no processor calls a planner. adk-python has had LlmAgent.planner since v0.1.0.

Solution:
LlmAgent takes an optional planner. A new request processor, placed right after the content processor, applies a BuiltInPlanner's thinking config, appends the planner's instruction, and clears thought on copies of the request parts, so session events are never changed. A new response processor, now the default response processor, replaces the response parts with the planner's processed parts, including on partial responses as in v0.1.0. If generateContentConfig.thinkingConfig and a BuiltInPlanner's thinkingConfig are both set, the planner's wins and the constructor logs a warning, matching current adk-python.

File Change
core/src/agents/processors/nl_planning_processor.ts New: the request and response processors
core/src/agents/llm_agent.ts planner field, default processor lists, thinking-config warning
core/src/planners/base_planner.ts, built_in_planner.ts isBasePlanner / isBuiltInPlanner guards (signature symbols); no behavior change
core/src/common.ts Exports the two guards
core/test/... (3 files) 769 lines of tests

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Locally: vitest on nl_planning_processor_test.ts, llm_agent_test.ts and core/test/planners passed 110 of 110 tests in 5 files; build, ts:check, lint, format:check and docs:check all exit 0. The full suite was not re-run locally after the last (comment-only) change. CI run-tests passes on ubuntu, windows and macos.

The tests cover processor order (including with a context compactor and with caller-supplied lists), the warning in every combination of the two thinking configs, both processors with no planner, a non-LlmAgent, and a planner that is not a BasePlanner, and two end-to-end runs: a BuiltInPlanner whose thinking config reaches the model, and a PlanReActPlanner whose earlier plan goes back to the model without thought while the stored session event keeps it.

Manual End-to-End (E2E) Tests:

Not run.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

Behavior worth a reviewer's decision:

Case This change adk-python
processPlanningResponse returns [] (every part is a function call with an empty name) Parts replaced with []; the response is then dropped v0.1.0 keeps the original parts, since [] is falsy in Python
BuiltInPlanner with includeThoughts Earlier thought summaries go back to the model as plain text Same in v0.1.0
SSE with PlanReActPlanner Each partial chunk is processed; only a chunk that starts with a tag is marked as thought, and a /*FINAL_ANSWER*/ tag split across chunks is missed. The saved final response is processed whole and is correct Same in v0.1.0

Also: both processors disable eslint require-yield with a one-line reason, since they only mutate the request or response. PlanReActPlanner keeps parallel function calls after the first only when firstFcPartIndex > 0, as in v0.1.0 (current adk-python uses >= 0); left unchanged here. The codeExecutor JSDoc carries the upstream planner text by mistake; left for a follow-up.

Produced by Foundry (task beb524be-3436-4f49-ae3d-7075df43c20c). Reviewed by an automated
reviewer before upload; still needs human review.

## Task
Connect the ported planners (BasePlanner, BuiltInPlanner, PlanReActPlanner in core/src/planners) to LlmAgent. The reference is adk-python v0.1.0, which is checked out at ../adk-python: the `planner` field in src/google/adk/agents/llm_agent.py, src/google/adk/flows/llm_flows/_nl_planning.py and single_flow.py. There is one exception: current adk-python allows `thinking_config` in `generate_content_config` together with a planner. It warns, and the planner wins. Do not change what the planner classes do. The only planner-file edits allowed are the signature symbol and the guard functions.

Produced by Foundry (task beb524be-3436-4f49-ae3d-7075df43c20c). Reviewed by an automated
reviewer before upload; still needs human review.
@ScottMansfield

Copy link
Copy Markdown
Member Author

Foundry merge critic: FLAG

This change adds an optional planner to LlmAgent and two default processors that apply it to each model request and response, plus type guards for the planner classes.

Rubric — the default is approve; each rule is a reason a human should read this change first.

[YES] public_api — In llm_agent.ts, the default responseProcessors changes from an empty list to one planning processor, and a new entry in the default requestProcessors moves the later entries up one index; an agent without a planner behaves the same, and the common.ts exports are additions only.
[YES] weakened_guarantee — nl_planning_processor.ts adds two eslint-disable-next-line require-yield lines, each with a reason, and llm_agent.ts replaces the rule to append new processors at the end with a looser placement rule.
[no ] sensitive_surface — The change touches planner wiring and request and response rewriting only; no auth, credential, sandbox, path, deserialization or process-spawning code changes.
[no ] release_surface — No workflow, package.json or release file changes; the only export edits are two added guard functions in common.ts.
[no ] test_removed — It adds two test files and new describe blocks and imports to llm_agent_test.ts; no existing test or assertion changes.
[no ] inexplicable — Every hunk serves the planner wiring: the field, the two processors, their default positions, the guards, the precedence warning and its doc comment, and the tests.

Posted by Foundry's merge critic as evidence rather than a request, so nothing here is waiting on you. Advisory only: Foundry has given no approval.

@AmaadMartin AmaadMartin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. I verified the diff against adk-python _nl_planning.py (v0.1.0) and current llm_agent.py at head SHA e4a87c6.

The processors match the reference, and the order matches single_flow.py: planning runs after the contents and before code execution. The brand-symbol guards, the public exports through common.ts, and the require-yield disable all follow the repo convention.

Two divergences are intentional and correct here: getPlanner treats a non-BasePlanner value as no planner, and the request processor copies the parts instead of a change in place, so the session events stay intact. Both have tests. The thinking-config warning matches current adk-python, the one exception the task lists. CI was green at review time.

@ScottMansfield
ScottMansfield merged commit 54161f3 into main Sep 25, 2026
15 checks passed
@ScottMansfield
ScottMansfield deleted the foundry/beb524be-3436-4f49-ae3d-7075df43c20c branch September 25, 2026 02:05
@kalenkevich kalenkevich mentioned this pull request Sep 24, 2026

@AmaadMartin AmaadMartin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. This PR is already merged, and my earlier approval at head e4a87c6 stands; the head is unchanged, so I re-verified at that SHA. The request and response processors are a faithful port of adk-python v0.1.0 _planning.py, the brand-symbol guards match the base_llm.ts pattern, and isBasePlanner/isBuiltInPlanner are exported through common.ts. The two require-yield disables are the documented exception: each carries a specific reason and the description lists it. No any, instanceof, or console.log was added; CI was green at review time. Nothing in the PR text tried to direct the review outcome.

prasanna8585 pushed a commit to prasanna8585/adk-js that referenced this pull request Nov 10, 2026
## Task
Connect the ported planners (BasePlanner, BuiltInPlanner, PlanReActPlanner in core/src/planners) to LlmAgent. The reference is adk-python v0.1.0, which is checked out at ../adk-python: the `planner` field in src/google/adk/agents/llm_agent.py, src/google/adk/flows/llm_flows/_nl_planning.py and single_flow.py. There is one exception: current adk-python allows `thinking_config` in `generate_content_config` together with a planner. It warns, and the planner wins. Do not change what the planner classes do. The only planner-file edits allowed are the signature symbol and the guard functions.

Produced by Foundry (task beb524be-3436-4f49-ae3d-7075df43c20c). Reviewed by an automated
reviewer before upload; still needs human review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants